class UiSelector(object):
    NEW = 'new UiSelector()'
    ID = '.resourceId'
    CLS_NAME = '.className'
    TEXT_CONTAINS = '.textContains'
    CHILD = '.childSelector'
    SIBLING = '.fromParent'

    @classmethod
    def uiautomator_code(cls,loc, parent_number):
        code = ''
        end = ''
        if isinstance(loc, tuple):
            return f'{cls.NEW}{loc[0]}("{loc[1]}")'
        for index, elem in enumerate(loc):
            if index < parent_number:
                code += f'{elem[0]}("{elem[1]}"){cls.CHILD}({cls.NEW}'
                end += ')'
            else:
                code += f'{elem[0]}("{elem[1]}")'
        return code